package com.wangdao.mall.dao;

import com.wangdao.mall.model.Type;
import com.wangdao.mall.utils.DruidUtils;
import org.apache.commons.dbutils.QueryRunner;
import org.apache.commons.dbutils.handlers.BeanListHandler;

import java.sql.SQLException;
import java.util.List;

/**
 * @Author:HaiyangTian
 * @Description:
 * @Date: Created in 22:03 2020/5/5
 * @Modified By:
 */
public class IndexDaoImp implements IndexDao {
    /**
     * 获取所有商品的分类
     * @return
     */
    @Override
    public List<Type> getType() {
        QueryRunner runner = new QueryRunner(DruidUtils.getDataSource());
        List<Type> typeList = null;
        try {
            typeList = runner.query("select * from type",
                    new BeanListHandler<Type>(Type.class));
        } catch (SQLException e) {
            e.printStackTrace();
        }
        return typeList;
    }
}
